
export const deepCopy = <T>(obj: any): T => {
    return JSON.parse(JSON.stringify(obj))
}


export const eliminateFloatRoundoffError = (s: string) => {
    if (s.indexOf('.') !== -1) {
        const fractionalPart = s.split('.')[1]
        if (fractionalPart.length > 10) {
            const parsedVal = parseFloat(s).toFixed(10)
            let indicator = parsedVal.length - 1
            while (parsedVal.substring(indicator, indicator + 1) == '0') {
                indicator -= 1
            }
            return parsedVal.substring(0, indicator + 1)
        }
    }

    return s
}


/**
 * 复制单行内容到粘贴板
 * content : 需要复制的内容
 */
export function copyToClip(content: string) {
    const aux = document.createElement("input");
    aux.setAttribute("value", content);
    document.body.appendChild(aux);
    aux.select();
    document.execCommand("copy");
    document.body.removeChild(aux);

}
